﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AD.BLL;
using AD.Model;
public partial class Manager_User_PageData_PresentCharge : WebManagerForm
{
    public string title = "";
    public string OneTimeMoney = "0.00";
    public int PresentBalancePoint = 0;
    public string remarks = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        string action = Request.QueryString["action"];
        if (!string.IsNullOrEmpty(action))
        {
            if (action.Equals("edit"))
            {
                PresentChargeMod presentCharge = PresentChargeBLL.QueryById(Request.QueryString["id"]);
                if (!Page.IsPostBack)
                {
                    if (presentCharge != null)
                    {
                        title = presentCharge.Title;
                        OneTimeMoney = presentCharge.OneTimeMoney.ToString("0.00");
                        PresentBalancePoint = presentCharge.PresentBalancePoint;
                        remarks = presentCharge.Remarks;
                    }
                }
                else {
                    if (presentCharge != null)
                    {
                        presentCharge.OneTimeMoney = double.Parse(Request["OneTimeMoney"]);
                        presentCharge.PresentBalancePoint = int.Parse(Request["PresentBalancePoint"]);
                        presentCharge.Title = Request["title"];
                        presentCharge.Remarks = Request["remarks"];
                        if (PresentChargeBLL.Update(presentCharge) > 0)
                        {
                            Alert("修改成功!");
                            RedirectNewURL("SystemSetting.aspx?action=gopage&pageIndex=1");
                        }
                        else {
                            Alert("修改失败!");
                        }
                    }
                }
            }
            else if (action.Equals("add"))
            {
                if (Page.IsPostBack)
                {
                    PresentChargeMod presentCharge = new PresentChargeMod();
                    presentCharge.OneTimeMoney = double.Parse(Request["OneTimeMoney"]);
                    presentCharge.PresentBalancePoint = int.Parse(Request["PresentBalancePoint"]);
                    presentCharge.Title = Request["title"];
                    presentCharge.Remarks = Request["remarks"];
                    if (PresentChargeBLL.Insert(presentCharge) > 0)
                    {
                        Alert("添加成功!");
                        RedirectNewURL("SystemSetting.aspx?action=gopage&pageIndex=1");
                    }
                    else
                    {
                        Alert("添加失败!");
                    }
                }
            }
        }
    }
}